package com.atguigu.schedule.Test;

import com.atguigu.schedule.dao.impl.BaseDao;
import com.atguigu.schedule.pojo.SysUser;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.List;

public class TestBaseDao {
    private static BaseDao baseDao;

    @BeforeClass
    public static void initBaseDao(){
        baseDao=new BaseDao();
    }

    @Test
    public void TestBaseQueryObject(){
        //查询用户数量 baseQueryObject 查询结果是单行单列的一个值的数据方法
        String sql="select count(1) from sys_user";
        Long count=baseDao.baseQueryObject(Long.class,sql);
        System.out.println(count);
    }

    @Test
    public void TestBaseQuery(){
        String sql="select uid,username,user_pwd userPwd from sys_user";
        List<Object> objects = baseDao.baseQuery(SysUser.class, sql);
        objects.forEach(System.out::println);
    }

    @Test
    public void TestBaseUpdate(){
        String sql="insert into sys_schedule values(DEFAULT,?,?,?)";
        int rows=baseDao.baseUpdate(sql,1,"学习JAVA",0);
        System.out.println(rows);
    }
}
